package com.wenbai.servicelightluxurystickers.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wenbai.servicelightluxurystickers.entity.StickComment;
import com.wenbai.servicelightluxurystickers.entity.dto.CommentPageQueryDto;
import com.wenbai.servicelightluxurystickers.entity.vo.parentUserVO;
import com.wenbai.servicelightluxurystickers.entity.vo.userVO;
import com.wenbai.servicelightluxurystickers.mapper.StickCommentMapper;
import com.wenbai.servicelightluxurystickers.service.StickCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StickCommentServiceImpl implements StickCommentService {

    @Autowired
    private StickCommentMapper stickCommentMapper;

    @Override
    public List<userVO> pageByPostId(CommentPageQueryDto commentPageQueryDto) {
        //开始分页查询
        PageHelper.startPage(commentPageQueryDto.getPage(),commentPageQueryDto.getPageSize());
        Page<userVO> page = stickCommentMapper.pageByPostId(commentPageQueryDto);
        return page.getResult();
    }

    @Override
    public List<parentUserVO> pageByCommentId(CommentPageQueryDto commentPageQueryDto) {
        PageHelper.startPage(commentPageQueryDto.getPage(),commentPageQueryDto.getPageSize());
        Page<parentUserVO> page = stickCommentMapper.pageByCommentId(commentPageQueryDto);
        return page.getResult();
    }

    @Override
    public void deleteByCommentId(Long commentId) {
        stickCommentMapper.deleteByCommentId(commentId);
    }

    @Override
    public void addCommentByPostId(StickComment stickComment){
        stickCommentMapper.insert(stickComment);
    }

}
